<?php
require_once LIB.'config.php';

class Database{
	private $connection;
	function __construct(){
		$this->openConnection();
	}
	function openConnection(){
		$this->connection = mysql_connect(DB_SERVER,DB_USER, DB_PASS);
		if(!$this->connection){
			die('Could not connect to Server'.mysql_error());
		}
		else {
			if(!mysql_select_db(DB_NAME)){
				die('Could not connect to database');
			}
			else {
				mysql_select_db(DB_NAME);
			}
		}
		
	}
	function close_connection(){
		if(isset($this->connection)){
			mysql_close($this->connection);
			unset($this->connection);
		}
	}
	function query($sql){
		$result = mysql_query($sql);
		return $result;
	}
	function fetch_array($resultset){
		return mysql_fetch_assoc($resultset);
	}
	
}

$database = new Database;


?>